<template>
  <div class="app-container">
    <div class="search-container">
      <el-form ref="queryFormRef" :model="queryForm" :inline="true">
        <!-- StartDate  EndDate -->
        <el-form-item prop="keywords">
          <el-input v-model="queryForm.keywords" placeholder="请输入关键字" clearable style="width: 200px" />
        </el-form-item>
        <el-form-item label="行业分类" prop="industryType">
          <el-select v-model="queryForm.industryType" clearable filterable placeholder="请选择">
            <el-option v-for="item in industryTypes" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="审核状态" prop="auditStatus">
          <el-select v-model="queryForm.auditStatus" clearable placeholder="请选择">
            <el-option v-for="item in projectAuditStatus" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="工程进度" prop="prjStatus">
          <el-select v-model="queryForm.prjStatus" clearable placeholder="请选择">
            <el-option v-for="item in projectStatus" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="所在城市" prop="areaCode" placeholder="请选择项目所在城市">
          <el-cascader
            v-model="queryForm.areaCode"
            clearable
            filterable
            placeholder="请选择项目所在城市"
            :options="areaoptions"
            @change="handleCascaderChange"
          />
        </el-form-item>
        <!-- <el-form-item label="所属地区">
          <el-tree-select
v-model="queryForm.areaCode" placeholder="选择所属地区" :data="areaoptions" filterable check-strictly
            :render-after-expand="false" />
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" style="margin-left: 0; border-radius: 0" @click="handleQuery"> 搜索 </el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="table-container">
      <el-row :gutter="20">
        <el-col :span="24" :offset="0">
          <el-button
            v-if="permissions.create"
            v-hasPerm="['sys:project:add']"
            type="primary"
            size="default"
            @click="handleCreate"
            >新增</el-button
          >
          <!-- <el-button
            v-if="permissions.complet"
            v-hasPerm="['sys:project:complete']"
            :disabled="!(currentProject && currentProject.needCompletData && currentProject.dataSource == 2)"
            type="primary"
            size="default"
            @click="handleComplet"
            >完善信息</el-button
          > -->
          <!-- <el-button v-if="permissions.changeStatus" type="primary" size="default" @click="handleChangeStatus"
            >操作项目状态</el-button
          > -->
          <el-button
            v-if="permissions.bindManager"
            v-hasPerm="['sys:project:bindmanager']"
            :disabled="!(currentProject && !currentProject.needCompletData)"
            type="primary"
            size="default"
            @click="handleBindManagerProjectInfo"
            >绑定劳资专管员</el-button
          >
          <!-- <el-button  v-if="permissions.isCreate" size="default" @click="Export">导出</el-button> -->
          <el-button
            v-if="permissions.import"
            v-hasPerm="['sys:project:import']"
            size="default"
            @click="handleBatchImport"
            >导入工程信息</el-button
          >
        </el-col>
        <el-col :span="24" :offset="0" style="margin-top: 10px">
          <el-table
            ref="tableRef"
            v-loading="loading"
            :data="tableData"
            style="width: 100%"
            :header-cell-class-name="selectionClass"
            @select="handleCurrentChange"
          >
            <el-table-column type="selection" align="center" width="50"> </el-table-column>
            <el-table-column label="项目名称" prop="name" min-width="250" />
            <el-table-column label="项目编号" prop="prjNum" min-width="200" />
            <el-table-column label="项目种类" prop="fundsSourceName" min-width="120" />
            <el-table-column label="行业分类" prop="industryTypeName" min-width="120" />
            <el-table-column label="监管单位" prop="deptName" min-width="120" />
            <el-table-column label="工程进度" prop="prjStatusName" min-width="80">
              <template #default="scope">
                <span v-if="scope.row.prjStatus == 1">
                  <el-text type="info"> {{ scope.row.prjStatusName }} </el-text>
                </span>
                <span v-if="scope.row.prjStatus == 2">
                  <el-text> {{ scope.row.prjStatusName }} </el-text>
                </span>
                <span v-if="scope.row.prjStatus == 3">
                  <el-text type="primary"> {{ scope.row.prjStatusName }} </el-text>
                </span>
                <span v-if="scope.row.prjStatus == 4">
                  <el-text type="warning"> {{ scope.row.prjStatusName }} </el-text>
                </span>
                <span v-if="scope.row.prjStatus == 5">
                  <el-text type="danger"> {{ scope.row.prjStatusName }} </el-text>
                </span>
                <span v-if="scope.row.prjStatus == 6">
                  <el-text type="success"> {{ scope.row.prjStatusName }} </el-text>
                </span>
              </template>
            </el-table-column>
            <el-table-column label="项目类型" prop="categoryName" min-width="100" />
            <el-table-column label="建设性质" prop="propertyNumName" min-width="80" />
            <!-- <el-table-column label="建设规模" prop="sizeTypeName" min-width="80" /> -->
            <el-table-column label="所在城市" prop="cityName" min-width="200" />
            <el-table-column label="项目状态" prop="auditStatusName" min-width="80">
              <template #default="scope">
                <span v-if="scope.row.auditStatus == 0">
                  <el-text type="warning">
                    {{ scope.row.dataSource == 4 ? "待登记" : scope.row.auditStatusName }}
                  </el-text>
                </span>
                <span v-if="scope.row.auditStatus == 1">
                  <el-text type="success"> {{ scope.row.auditStatusName }} </el-text>
                </span>
                <span v-if="scope.row.auditStatus == -1">
                  <el-tooltip effect="light" :content="scope.row.auditReason" placement="top">
                    <el-text type="danger"> {{ scope.row.auditStatusName }} </el-text></el-tooltip
                  >
                </span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="currentSystem == 'SysUser' || currentSystem == 'Corp'"
              label="劳资专管员"
              prop="managerName"
              min-width="120"
            />
            <el-table-column
              v-if="currentSystem == 'SysUser' || currentSystem == 'Corp'"
              label="劳资专管员账号"
              prop="managerCardNumber"
              min-width="120"
            />
            <el-table-column label="实际开工时间" prop="startDate" min-width="120" />
            <el-table-column label="操作" fixed="right" max-width="360" :min-width="200">
              <template #default="scope">
                <el-button
                  v-if="
                    (permissions.update && scope.row.auditStatus < 1 && scope.row.dataSource != 4) ||
                    currentSystem == 'SysUser'
                  "
                  v-hasPerm="['sys:project:update']"
                  v-hasData="scope.row.hasEdit"
                  link
                  size="small"
                  type="primary"
                  @click="handleEdit(scope.row)"
                >
                  修改
                </el-button>
                <el-button
                  v-if="permissions.delete && scope.row.auditStatus < 1 && scope.row.dataSource != 4"
                  v-hasData="scope.row.hasEdit"
                  v-hasPerm="['sys:project:delete']"
                  type="primary"
                  link
                  size="small"
                  @click="handleDelete(scope.row)"
                >
                  删除
                </el-button>
                <el-button
                  v-if="permissions.auditing && scope.row.auditStatus == 0 && !scope.row.needCompletData"
                  v-hasPerm="['sys:project:audit']"
                  v-hasData="scope.row.hasEdit"
                  type="primary"
                  link
                  size="small"
                  @click="handleAudit(scope.row)"
                >
                  审核
                </el-button>
                <el-button
                  v-if="permissions.updateApply && scope.row.auditStatus == 1"
                  v-hasData="scope.row.hasEdit"
                  type="primary"
                  link
                  :disabled="scope.row.existUpdate"
                  size="small"
                  @click="handelUpdateApply(scope.row)"
                >
                  {{ scope.row.existUpdate ? "修改申请中" : "修改申请" }}
                </el-button>
                <el-button
                  v-if="permissions.auditUpdate && scope.row.existUpdate && scope.row.auditStatus == 1"
                  v-hasPerm="['sys:project:auditupdate']"
                  v-hasData="scope.row.hasEdit"
                  type="primary"
                  link
                  size="small"
                  @click="handelAuditUpdate(scope.row)"
                >
                  修改审核
                </el-button>
                <el-button
                  v-if="permissions.resetPassword && scope.row.managerId > 0 && scope.row.auditStatus == 1"
                  v-hasPerm="['sys:project:resetManagerPassWord']"
                  v-hasData="scope.row.hasEdit"
                  type="primary"
                  link
                  size="small"
                  @click="handelResetPassword(scope.row)"
                >
                  重置劳资专管员密码
                </el-button>
                <el-button
                  v-if="
                    permissions.sync && scope.row.industryType == 1 && !scope.row.isSync && scope.row.auditStatus == 1
                  "
                  v-hasData="scope.row.hasEdit"
                  type="primary"
                  link
                  size="small"
                  @click="handelSync(scope.row)"
                >
                  同步
                </el-button>
                <el-button
                  v-show="permissions.push && scope.row.industryType == 1 && scope.row.auditStatus == 1"
                  v-hasData="scope.row.hasEdit"
                  type="primary"
                  link
                  size="small"
                  @click="handelPush(scope.row)"
                >
                  推送
                </el-button>
                <el-button
                  v-if="permissions.detail"
                  v-hasPerm="['sys:project:detail']"
                  type="primary"
                  link
                  size="small"
                  @click="handleDetail(scope.row)"
                >
                  详情
                </el-button>
                <el-button
                  v-if="permissions.complet && scope.row.auditStatus == 1"
                  v-hasData="scope.row.hasEdit"
                  type="primary"
                  link
                  size="small"
                  @click="handleComplet(scope.row)"
                >
                  完善信息
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="total > 0"
            v-model:total="total"
            v-model:page="queryForm.pageIndex"
            v-model:limit="queryForm.pageSize"
            @pagination="handleQuery"
          />
        </el-col>
      </el-row>
    </div>
    <add-form v-if="dialogAddOrEdit.visible" :dialog-add-or-edit="dialogAddOrEdit" @send-close="sendClose" />
    <bind-manager v-if="dialogBindManager.visible" :dialog-bind-manager="dialogBindManager" @send-close="sendClose" />
    <complet-form v-if="dialogCompletForm.visible" :dialog-complet-form="dialogCompletForm" @send-close="sendClose" />
    <detail v-if="dialogDetail.visible" :dialog-detail="dialogDetail" @send-close="sendClose" />
    <import-excel
      v-if="dialogImportExcel.visible"
      :dialog-import-excel="dialogImportExcel"
      @send-close="sendClose"
    ></import-excel>
    <audit-update :dialog-audit-update="dialogAuditUpdate" @send-close="sendClose" />
    <update-apply :dialog-update-apply="dialogUpdateApply" @send-close="sendClose" />
  </div>
</template>
<script setup lang="ts">
import addForm from "./addForm.vue";
import bindManager from "./bindManager.vue";
import completForm from "./completForm.vue";
import importExcel from "./importExcel.vue";
import auditUpdate from "./auditUpdate.vue";
import updateApply from "./updateApply.vue";
import PasswordInput from "@/components/PasswordInput/index.vue";

import detail from "./detail.vue";
import {
  QueryProjectPage,
  DeleteProject,
  auditProject,
  ExistsUpdateApply,
  ResetManagerPassWord,
  SyncProject,
  PublishProject,
} from "@/api/project/projectInfo/index";
import { getDicts } from "@/store/modules/dict";
import { ElRadioGroup, ElRadioButton, ElFormItem, ElInfiniteScroll, ElInput } from "element-plus";

const permissions = ref<any>({
  create: false,
  update: false,
  delete: false,
  detail: false,
  complet: false,
  bindManager: false,
  changeStatus: false,
  auditing: false,
  device: false,
  auditUpdate: false,
  updateApply: false,
  import: false,
  resetPassword: false,
  sync: false,
  push: false,
});

const currentSystem = ref(localStorage.getItem("usertypeName"));
const isLumpContractor = ref(localStorage.getItem("isLumpContractor"));
const industryTypes = getDicts("projectIndustryTypes");
const projectAuditStatus = getDicts("projectAuditStatus");
const projectStatus = getDicts("projectStatus");
//行政区划
const areaoptions = getDicts("areaTrees").filter((item: { value: number }) => item.value === 540000);

//城市联动赋值
const handleCascaderChange = (value: any) => {
  if (value.length == 3) {
    queryForm.provinceCode = value[0];
    queryForm.cityCode = value[1];
    queryForm.areaCode = value[2];
  }
  // 在这里可以对选中的值进行进一步处理
};

if (currentSystem.value == "SysUser") {
  permissions.value = {
    create: true,
    update: true,
    delete: true,
    detail: true,
    complet: true,
    bindManager: true,
    changeStatus: false,
    auditing: true,
    device: false,
    auditUpdate: true,
    updateApply: false,
    import: true,
    resetPassword: true,
    sync: false,
    push: false,
  };
}
if (currentSystem.value == "Corp") {
  if (isLumpContractor.value) {
    permissions.value = {
      create: true,
      update: true,
      delete: true,
      detail: true,
      complet: true,
      bindManager: true,
      changeStatus: true,
      auditing: false,
      device: true,
      auditUpdate: false,
      updateApply: false,
      import: false,
      resetPassword: true,
      sync: true,
      push: true,
    };
  } else {
    permissions.value.detail = true;
  }
}
if (currentSystem.value == "Constructor") {
  permissions.value.detail = true;
  permissions.value.auditUpdate = true;
}
if (currentSystem.value == "Manager") {
  permissions.value.create = false;
  permissions.value.update = true;
  permissions.value.delete = true;
  permissions.value.detail = true;
  permissions.value.complet = true;
  permissions.value.updateApply = true;
  permissions.value.sync = true;
  permissions.value.push = true;
}
if (currentSystem.value == "Commander") {
  permissions.value.detail = true;
  permissions.value.complet = true;
}

console.log(isLumpContractor);
console.log(currentSystem);
const loading = ref(false);
const tableData = ref();
const areaTrees = getDicts("areaTrees")?.filter((item: any) => item.value === 540000);

// const toDeviceMgr = (id: number) => {
//   const href = router.resolve({
//     //使用resolve
//     path: "/attdevicemgr",
//     query: { projectId: id },
//   });
//   // 点击事件
//   window.open(href.href, "_blank");
//   // router.push({ path: "/attdevicemgr", query: { projectId: id } });
// };
const dialogAddOrEdit = reactive<DialogOption>({
  visible: false,
});
const dialogBindManager = reactive<DialogOption>({
  visible: false,
});
const dialogCompletForm = reactive<DialogOption>({
  visible: false,
});
const dialogDetail = reactive<DialogOption>({
  visible: false,
});
const dialogImportExcel = reactive<DialogOption>({
  visible: false,
});
const dialogAuditUpdate = reactive<DialogOption>({
  visible: false,
});
const dialogUpdateApply = reactive<DialogOption>({
  visible: false,
});

const currentProject = ref();
const tableRef = ref();

//实现复选框的单选
const handleCurrentChange = function (selections: any, row: any) {
  if (selections.length > 1) {
    // 把数组的第一个元素从其中删除
    let del_row = selections.shift();
    // 用于多选表格，切换某一行的选中状态，如果使用了第二个参数，则是设置这一行选中与否（selected 为 true 则选中）
    tableRef.value.toggleRowSelection(del_row, false);
    currentProject.value = selections[0];
  } else {
    currentProject.value = selections[0];
  }
};

const handleBatchImport = () => {
  dialogImportExcel.visible = true;
  dialogImportExcel.visible = true;
  dialogImportExcel.title = "导入项目基本信息";
};
const passwordForm = ref({
  password: "",
});
const validatePassword = ref<boolean>(false);
const handelResetPassword = function (row: any) {
  ElMessageBox({
    title: "确定重置劳资专管员密码？",
    message: () =>
      h("div", [
        h(
          ElForm,
          {
            model: passwordForm,
            labelWidth: "80px",
          },
          [
            h(
              ElFormItem,
              {
                rules: [
                  {
                    required: true,
                    message: "请输入密码",
                  },
                ],
                label: "密码",
                prop: "password",
              },
              [
                h(PasswordInput, {
                  onInputChange: (value: string, allow: boolean) => {
                    passwordForm.value.password = value;
                    validatePassword.value = allow;
                  },
                }),
              ]
            ),
          ]
        ),
      ]),
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    showCancelButton: true,
    beforeClose(action, instance, done) {
      if (action === "confirm") {
        if (!validatePassword.value) return;
        instance.confirmButtonLoading = true;
        instance.confirmButtonText = "执行中...";
        ResetManagerPassWord(row.projectId, passwordForm.value.password)
          .then((res) => {
            if (res.success) {
              ElMessage({
                type: "success",
                message: res.msg,
              });
              instance.confirmButtonLoading = false;
              instance.confirmButtonText = "确定";
              done();
            } else {
              ElMessage({
                type: "error",
                message: res.msg,
              });
            }
          })
          .finally(() => {
            loading.value = false;
          });
      } else {
        done();
      }
    },
  });
};

//审核修改申请
const handelAuditUpdate = async (row: any) => {
  loading.value = true;
  let res = await ExistsUpdateApply(row.projectId);
  loading.value = false;
  if (!res.success) {
    return;
  }
  if (!res.data) {
    ElMessage.warning("该项目不存在修改申请");
    return;
  }
  dialogAuditUpdate.visible = true;
  dialogAuditUpdate.title = "修改审核【" + row.name + "】";
  dialogAuditUpdate.id = row.projectId;
};

//提出修改申请
const handelUpdateApply = async (row: any) => {
  loading.value = true;
  let res = await ExistsUpdateApply(row.projectId);
  loading.value = false;
  if (!res.success) {
    return;
  }
  if (res.data) {
    ElMessage.warning("存在未审核的修改申请，请审核后再提交");
    return;
  }
  dialogUpdateApply.visible = true;
  dialogUpdateApply.title = "修改申请";
  dialogUpdateApply.id = row.projectId;
  dialogUpdateApply.type = row.industryType;
};

//新增
const handleCreate = function () {
  dialogAddOrEdit.visible = true;
  dialogAddOrEdit.footBtn = "确认新增";
  dialogAddOrEdit.title = "新增";
};
//编辑
const handleEdit = function (row: any) {
  dialogAddOrEdit.visible = true;
  dialogAddOrEdit.id = row.projectId;
  dialogAddOrEdit.footBtn = "确认修改";
  dialogAddOrEdit.title = "修改";
};
//完善信息
const handleComplet = function (row: any) {
  dialogCompletForm.id = row.projectId;
  dialogCompletForm.visible = true;
  dialogCompletForm.title = "完善";
  dialogCompletForm.footBtn = "保存";
};
const auditResult = ref("通过");
const auditReason = ref("");
const handleAudit = async function (row: any) {
  auditResult.value = "通过";
  auditReason.value = "";
  let box = await ElMessageBox({
    title: "项目审核",
    showCancelButton: true,
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    message: () =>
      h(
        ElForm,
        {
          labelWidth: "120px",
        },
        [
          h(
            ElFormItem,
            {
              label: "审核结果",
            },
            [
              h(
                ElRadioGroup,
                {
                  modelValue: auditResult.value,
                  style: { width: "" },
                  "onUpdate:modelValue": (val: any) => {
                    auditResult.value = val;
                  },
                },
                [
                  h(ElRadioButton, {
                    label: "通过",
                  }),
                  h(ElRadioButton, {
                    label: "不通过",
                  }),
                ]
              ),
            ]
          ),
          h(
            ElFormItem,
            {
              label: "审核结果说明",
            },
            [
              h(ElInput, {
                modelValue: auditReason.value,
                style: { width: "" },
                "onUpdate:modelValue": (val: any) => {
                  auditReason.value = val;
                },
              }),
            ]
          ),
        ]
      ),
  })
    .then((val) => true)
    .catch((val) => false);
  if (!box) {
    ElMessage({
      type: "info",
      message: "已取消审核！",
    });
    return;
  }
  loading.value = true;
  auditProject(Number(row.projectId), {
    auditStatus: auditResult.value === "通过" ? 1 : -1,
    auditReason: auditReason.value,
  })
    .then((data) => {
      if (data.success) {
        ElMessage({
          type: "success",
          message: "审核成功！",
        });
        handleQuery();
      } else {
        ElMessage({
          type: "error",
          message: data?.msg,
        });
      }
    })
    .catch((e) => {
      ElMessage({
        type: "error",
        message: e.toString(),
      });
    })
    .finally(() => {
      loading.value = false;
    });
};
//操作状态
const handleChangeStatus = function () {
  if (!currentProject.value) {
    ElMessage.warning("请选择项目");
    return;
  }
  dialogBindManager.visible = true;
};
//绑定劳资管理员
const handleBindManagerProjectInfo = function () {
  let list = tableRef.value.getSelectionRows();
  if (list.length == 0) {
    ElMessage.warning("请选择项目");
    return;
  }
  if (list.length > 1) {
    ElMessage.warning("只能选择一条数据");
    return;
  }
  currentProject.value = list[0];
  if (!currentProject.value) {
    ElMessage.warning("请选择项目");
    return;
  }
  dialogBindManager.id = currentProject.value.projectId;
  dialogBindManager.visible = true;
  dialogBindManager.title = "绑定劳资管理员";
  dialogBindManager.footBtn = "确认绑定";
};
//详情
const handleDetail = function (row: any) {
  // debugger;
  // router.push("/manager/project/projectinfo/detail");
  // return;
  // router.push({ path: "/manager/project/projectinfo/detail", query: { id: row.projectId } });
  // return;
  dialogDetail.visible = true;
  dialogDetail.id = row.projectId;
  dialogDetail.title = "详情";
};

const sendClose = function (needRefresh: boolean) {
  dialogAddOrEdit.visible = false;
  dialogAddOrEdit.id = undefined;
  dialogCompletForm.visible = false;
  dialogCompletForm.id = undefined;
  dialogBindManager.visible = false;
  dialogBindManager.id = undefined;
  dialogDetail.visible = false;
  dialogDetail.id = undefined;
  dialogImportExcel.visible = false;
  dialogAuditUpdate.visible = false;
  dialogUpdateApply.visible = false;
  if (needRefresh) {
    handleQuery();
  }
};

//删除
const handleDelete = function (row: any) {
  ElMessageBox.confirm("确定删除该项目吗？", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      loading.value = true;
      DeleteProject(row.projectId)
        .then((res) => {
          if (res.success) {
            ElMessage({
              type: "success",
              message: res.msg,
            });
            handleQuery();
          } else {
            ElMessage({
              type: "error",
              message: res.msg,
            });
            loading.value = false;
          }
        })
        .catch(() => {
          loading.value = false;
        });
    })
    .catch(() => {
      console.log("取消");
    });
};
//同步
const handelSync = function (row: any) {
  ElMessageBox.confirm("确定同步该项目吗？", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      loading.value = true;
      SyncProject(row.projectId)
        .then((res) => {
          if (res.success) {
            ElMessage({
              type: "success",
              message: res.msg,
            });
            handleQuery();
          } else {
            ElMessage({
              type: "error",
              message: res.msg,
            });
            loading.value = false;
          }
        })
        .catch(() => {
          loading.value = false;
        });
    })
    .catch(() => {
      console.log("取消");
    });
};
//推送
const handelPush = function (row: any) {
  ElMessageBox.confirm("确定推送该项目吗？", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      loading.value = true;
      PublishProject(row.projectId)
        .then((res) => {
          if (res.success) {
            ElMessage({
              type: "success",
              message: res.msg,
            });
            handleQuery();
          } else {
            ElMessage({
              type: "error",
              message: res.msg,
            });
            loading.value = false;
          }
        })
        .catch(() => {
          loading.value = false;
        });
    })
    .catch(() => {
      console.log("取消");
    });
};

//查询条件
const queryForm = reactive({
  keywords: "",
  industryType: null,
  auditStatus: null,
  prjStatus: null,
  provinceCode: null,
  cityCode: null,
  areaCode: null,
  pageIndex: 1,
  pageSize: 10,
});
const total = ref(0);
const selectionClass = (row: any) => {
  if (row.columnIndex === 0) {
    return "disabledCheck";
  }
};

const fomartCityName = function (cityCode: string) {
  let cityName = "";
  if (!cityCode) return "";
  areaTrees[0].children.forEach((i: any) => {
    if (i.value == cityCode) {
      console.log(i.label);
      cityName = i.label;
    }
    if (i.children) {
      i.children.forEach((j: any) => {
        if (j.value == cityCode) {
          console.log(j.label);
          cityName = j.label;
        }
      });
    }
  });
  return cityName;
};
//这是列表数据
const handleQuery = function () {
  loading.value = true;
  QueryProjectPage(queryForm)
    .then((res) => {
      if (res.success) {
        tableData.value = res.data.list;
        queryForm.pageIndex = res.data.pageNum;
        queryForm.pageSize = res.data.pageSize;
        total.value = res.data.total;
      }
    })
    .finally(() => {
      loading.value = false;
    });
};

onMounted(() => {
  handleQuery();
});
</script>
<style scoped>
:deep(.el-button) {
  margin-left: 5px;
}

:deep(.el-input__wrapper) {
  border-radius: 0;
}

:deep(.el-table .disabledCheck .cell .el-checkbox__inner) {
  display: none;
}

.deep(.table-edit-btns) {
  display: inline-block;
}
</style>
